package com.zsc.wxm.ysh.anjo.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 输出异常信息工具类
 *
 * @author playmaker
 * @since 2021-01-19
 */
public class ExceptionUtil {

    private ExceptionUtil() {

    }

    public static String getMessage(Exception e){
        StringWriter stringWriter = new StringWriter();
        try (PrintWriter printWriter = new PrintWriter(stringWriter)) {
            //将错误的堆栈信息输出到writer中
            e.printStackTrace(printWriter);
            printWriter.flush();
            stringWriter.flush();
        }
        return stringWriter.toString();
    }
}
